// 方式 1：List 作为 Iterable
Iterable<Integer> range(int start, int end){
    List<Integer> ints = new ArrayList<Integer>();
    for (int i = start; i <= end; i++) {
        ints.add(i);
    }
    return ints;
}

for(int i : range(1,10)){
//...
}

// 方式 2：实现 Iterator 接口
class Range implements Iterator<Integer> {
    private int nextValue;
    private final int max;
    public Range(int min, int max) {
      this.nextValue = min;
      this.max = max;
    }
    public boolean hasNext() {
      return nextValue <= max;
    }
    public Integer next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      return Integer.valueOf(nextValue++);
    }
  }